package com.lanjiu.lib.imclient.ims.send;

import android.text.TextUtils;

import com.lanjiu.lib.imclient.dto.DelGroupMsgDto;
import com.lanjiu.lib.imclient.dto.DeleteMessageDto;
import com.lanjiu.lib.imclient.dto.VersionDto;
import com.lanjiu.lib.imclient.dto.extra.InviteDto;
import com.lanjiu.lib.utils.ParseUtils;
import com.lanjiu.lib.utils.log.Logger;
import com.lanjiu.pro.business.BusinessProtocolEntities;
import com.lanjiu.pro.business.BusinessProtocolMessageStandard;
import com.lanjiu.pro.business.BusinessProtocolMessages;
import com.lanjiu.lib.app.App;
import com.lanjiu.lib.communication.util.JCRC32;
import com.lanjiu.lib.imclient.bus.EventConstants;
import com.lanjiu.lib.imclient.bus.MessageEvent;
import com.lanjiu.lib.imclient.dto.FriendDto;
import com.lanjiu.lib.imclient.dto.GroupDto;
import com.lanjiu.lib.imclient.dto.GroupMemberDto;
import com.lanjiu.lib.imclient.dto.user.RegisteredUserDto;
import com.lanjiu.lib.imclient.dto.SearchDto;
import com.lanjiu.lib.imclient.dto.SettingsDto;
import com.lanjiu.lib.imclient.dto.user.TouristsUserDto;
import com.lanjiu.lib.imclient.dto.base.Dto;
import com.lanjiu.lib.imclient.dto.extra.ChatFriendMsgDto;
import com.lanjiu.lib.imclient.dto.extra.ChatGroupMsgDto;
import com.lanjiu.lib.imclient.dto.extra.RegisteredUserSettingsDto;
import com.lanjiu.lib.imclient.ims.IMSContacts;
import com.lanjiu.lib.imclient.user.UserPreferences;
import com.lanjiu.lib.utils.DeviceUtils;
import com.lanjiu.lib.utils.GUID;
import com.ljkj.cordial.chat.ui.ChatUtils;
import com.nic.view.util.JLog;

/**
 * @description:
 * @author: Panwei
 * @date: 2019/11/8 17:44
 */
public class IMSMessageSender {

    private JCRC32 mJcrc32;

    public IMSMessageSender() {
        mJcrc32 = new JCRC32();
    }

    public BusinessProtocolMessageStandard.CheckUnifiedEntranceMessage getSend(MessageEvent messageEvent) {
        BusinessProtocolMessageStandard.UnifiedEntranceMessage mMessage = getUnifiedEntranceMessage(messageEvent);
        if (mMessage != null) {
            return mJcrc32.packageCheckSum(mMessage);
        } else {
            return null;
        }
    }

    private BusinessProtocolMessageStandard.UnifiedEntranceMessage getUnifiedEntranceMessage(MessageEvent messageEvent) {
        if (null == messageEvent) return null;
        BusinessProtocolMessageStandard.UnifiedEntranceMessage message = null;
        switch (messageEvent.action()) {
            case EventConstants.Action.REGISTER:
                message = onRegisterResponseSender(messageEvent.data());
                break;
            case EventConstants.Action.LOGIN_TOURISTS:
                message = onLoginAsTouristsSender();
                break;
            case EventConstants.Action.LOGIN_REGISTERED:
                message = onLoginAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.LOGOUT_TOURISTS:
                message = onLogoutAsTouristsSender();
                break;
            case EventConstants.Action.LOGOUT_REGISTERED:
                message = onLogoutAsRegisteredSender();
                break;
            case EventConstants.Action.FRIEND_FIND_TOURISTS:
                message = onFriendFindAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_FIND_REGISTERED:
                message = onFriendFindAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_LIST_TOURISTS:
                message = onFriendListAsTouristsSender();
                break;
            case EventConstants.Action.FRIEND_LIST_REGISTERED:
                message = onFriendListAsRegisteredSender();
                break;
            case EventConstants.Action.FRIEND_INFO_TOURISTS:
                message = onFriendInfoAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_INFO_REGISTERED:
                message = onFriendInfoAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_ONLINE_STATUS_TOURISTS:
                message = onFriendOnlineStatusChangeAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_ONLINE_STATUS_REGISTERED:
                message = onFriendOnlineStatusChangeAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_APPLY_TOURISTS:
                message = onFriendApplyAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_APPLY_REGISTERED:
                message = onFriendApplyAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_APPLY_AGREE_TOURISTS:
                message = onFriendApplyAgreeAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_APPLY_AGREE_REGISTERED:
                message = onFriendApplyAgreeAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_APPLY_REFUSE_TOURISTS:
                message = onFriendApplyRefuseAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_APPLY_REFUSE_REGISTERED:
                message = onFriendApplyRefuseAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_DELETE_TOURISTS:
                message = onFriendDeleteAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_DELETE_REGISTERED:
                message = onFriendDeleteAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_FIND_TOURISTS:
                message = onGroupFindAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_FIND_REGISTERED:
                message = onGroupFindAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_LIST_TOURISTS:
                message = onGroupListAsTouristsSender();
                break;
            case EventConstants.Action.GROUP_LIST_REGISTERED:
                message = onGroupListAsRegisteredSender();
                break;
            case EventConstants.Action.GROUP_CREATE_TOURISTS:
                message = onGroupCreateAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_CREATE_REGISTERED:
                message = onGroupCreateAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_INFO_TOURISTS:
                message = onGroupInfoAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_INFO_REGISTERED:
                message = onGroupInfoAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_ONLINE_STATUS_TOURISTS:
                message = onGroupMemberOnlineStatusChangeAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_ONLINE_STATUS_REGISTERED:
                message = onGroupMemberOnlineStatusChangeAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_INVITE_TOURISTS:
                message = onGroupMemberInviteAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_INVITE_REGISTERED:
                message = onGroupMemberInviteAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_INVITE_AGREE_TOURISTS:
                message = onGroupMemberInviteAgreeAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_INVITE_AGREE_REGISTERED:
                message = onGroupMemberInviteAgreeAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_INVITE_REFUSE_TOURISTS:
                message = onGroupMemberInviteRefuseAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_INVITE_REFUSE_REGISTERED:
                message = onGroupMemberInviteRefuseAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_APPLY_TOURISTS:
                message = onGroupMemberApplyAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_APPLY_REGISTERED:
                message = onGroupMemberApplyAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_APPLY_AGREE_TOURISTS:
                message = onGroupMemberApplyAgreeAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_APPLY_AGREE_REGISTERED:
                message = onGroupMemberApplyAgreeAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_APPLY_REFUSE_TOURISTS:
                message = onGroupMemberApplyRefuseAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_APPLY_REFUSE_REGISTERED:
                message = onGroupMemberApplyRefuseAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_DELETE:
                message = onGroupMemberDeleteSender(messageEvent.data());
//                Logger.print("Sender", "踢人LOGIN\n" + message);
                break;
            case EventConstants.Action.GROUP_MEMBER_EXIT:
                message = onGroupMemberExitSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_DELETE_TOURISTS:
                message = onGroupMemberDeleteAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_DELETE_REGISTERED:
                message = onGroupMemberDeleteAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_ANNOUNCEMENT_UPDATE_TOURISTS:
                message = onGroupAnnouncementUpdateAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_ANNOUNCEMENT_UPDATE_REGISTERED:
                message = onGroupAnnouncementUpdateAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_NICKNAME_TOURISTS:
                message = onPersonalNicknameAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_NICKNAME_REGISTERED:
                message = onPersonalNicknameAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_AVATAR_TOURISTS:
                message = onPersonalAvatarAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_AVATAR_REGISTERED:
                message = onPersonalAvatarAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.VERIFICATION_CODE:
                message = onPersonalVerificationCodeSender(messageEvent.data());
                break;
            case EventConstants.Action.VERIFICATION_CODE_NO_LOGIN:
                message = onNotLoginVerificationCodeSender(messageEvent.data());
                break;
            case EventConstants.Action.RESET_SECRET_VERIFY:
                message = onPersonalResetSecretVerifySender(messageEvent.data());
                break;
            case EventConstants.Action.RESET_SECRET:
                message = onPersonalResetSecretSender(messageEvent.data());
//                Logger.print("Sender", "重置密码LOGIN\n" + message);
                break;
            case EventConstants.Action.RESET_SECRET_NO_LOGIN:
                message = onNotLoginResetSecretSender(messageEvent.data());
//                Logger.print("Sender", "重置密码NO_LOGIN\n" + message);
                break;
            case EventConstants.Action.SETUP_PHONE:
                message = onPersonalSetupPhoneSender(messageEvent.data());
                break;
            case EventConstants.Action.SETUP_PHONE_EDIT:
                message = onPersonalEditPhoneSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_OFFLINE_MSG_TOURISTS:
                message = onPersonalOfflineMsgAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_OFFLINE_MSG_REGISTERED:
                message = onPersonalOfflineMsgAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_FRIEND_SNAPCHAT_TOURISTS:
                message = onPersonalFriendSnapchatAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_FRIEND_SNAPCHAT_REGISTERED:
                message = onPersonalFriendSnapchatAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_FRIEND_SNAPCHAT_LENGTH_TOURISTS:
                message = onPersonalFriendSnapchatLengthAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_FRIEND_SNAPCHAT_LENGTH_REGISTERED:
                message = onPersonalFriendSnapchatLengthAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_GROUP_SNAPCHAT_TOURISTS:
                message = onPersonalGroupSnapchatAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_GROUP_SNAPCHAT_REGISTERED:
                message = onPersonalGroupSnapchatAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_GROUP_SNAPCHAT_LENGTH_TOURISTS:
                message = onPersonalGroupSnapchatLengthAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_GROUP_SNAPCHAT_LENGTH_REGISTERED:
                message = onPersonalGroupSnapchatLengthAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_EXIT_CLEAN_TOURISTS:
                message = onPersonalExitCleanAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_EXIT_CLEAN_REGISTERED:
                message = onPersonalExitCleanAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_TIMER_CLEAN_TOURISTS:
                message = onPersonalTimerCleanAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.PERSONAL_TIMER_CLEAN_REGISTERED:
                message = onPersonalTimerCleanAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_ALIAS_TOURISTS:
                message = onFriendAliasAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_ALIAS_REGISTERED:
                message = onFriendAliasAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_SNAPCHAT_TOURISTS:
                message = onFriendSnapchatAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_SNAPCHAT_REGISTERED:
                message = onFriendSnapchatAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_SNAPCHAT_LENGTH_TOURISTS:
                message = onFriendSnapchatLengthAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_SNAPCHAT_LENGTH_REGISTERED:
                message = onFriendSnapchatLengthAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_OFFLINE_MSG_TOURISTS:
                message = onFriendOfflineMsgAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.FRIEND_OFFLINE_MSG_REGISTERED:
                message = onFriendOfflineMsgAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_NAME_TOURISTS:
                message = onGroupNameAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_NAME_REGISTERED:
                message = onGroupNameAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_SNAPCHAT_TOURISTS:
                message = onGroupSnapchatAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_SNAPCHAT_REGISTERED:
                message = onGroupSnapchatAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_SNAPCHAT_LENGTH_TOURISTS:
                message = onGroupSnapchatLengthAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_SNAPCHAT_LENGTH_REGISTERED:
                message = onGroupSnapchatLengthAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_NICK_TOURISTS:
                message = onGroupMemberNickAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_NICK_REGISTERED:
                message = onGroupMemberNickAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_ALIAS_TOURISTS:
                message = onGroupMemberAliasAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_MEMBER_ALIAS_REGISTERED:
                message = onGroupMemberAliasAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.NOTIFICATIONS_TOURISTS:
                message = onNotificationsAsTouristsSender();
                break;
            case EventConstants.Action.NOTIFICATIONS_REGISTERED:
                message = onNotificationsAsRegisteredSender();
                break;
            case EventConstants.Action.FRIEND_CHAT_TOURISTS:
            case EventConstants.Action.FRIEND_CHAT_REGISTERED:
                message = onFriendChatMessageSender(messageEvent.data());
//                Logger.print("Sender", "发送的好友消息\n"+message);
                break;
            case EventConstants.Action.GROUP_CHAT_TOURISTS:
            case EventConstants.Action.GROUP_CHAT_REGISTERED:
                message = onGroupChatMessageSender(messageEvent.data());
//                Logger.print("Sender", "发送的群组消息\n"+message);
                break;
            case EventConstants.Action.DEL_FRIEND_OFF_MESSAGE_TOURIST:
                message = onDelFriendMessageAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.DEL_FRIEND_OFF_MESSAGE_REGIST:
                message = onDelFriendMessageAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.OFF_MESSAGE_SEND_TOURIST:
                message = onOffFriendMessageAsTouristsSender(messageEvent.data());
                break;
            case EventConstants.Action.OFF_MESSAGE_SEND_REGIST:
                message = onOffFriendMessageAsRegisteredSender(messageEvent.data());
                break;
            case EventConstants.Action.GROUP_CHART_OFF_LINE_MSG:
                message = onGroupOfflineMessageSender(messageEvent.data());
                break;
            case EventConstants.Action.CHECK_FOR_UPDATES:
                message = onCheckForUpdatesSender(messageEvent.data());
                break;
            case EventConstants.Action.DEL_GROUP_OFF_MESSAGE:
                message = onDelGroupMessageSender(messageEvent.data());
//                Logger.print("Sender", "发送的群组消息删除\n" + message);
                break;
            case EventConstants.Action.PERSONAL_SETTINGS_INFO:
                message = onPersonalSettingsMessageSender();
                break;
        }
        return message;
    }

    // 注册
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onRegisterResponseSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        RegisteredUserDto userDto = Dto.fromJson(params, RegisteredUserDto.class);
        if (null == userDto) return null;
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.REGISTER)
                .setFromId(DeviceUtils.getDeviceId(App.getContext()))
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.RegisteredUserProtocol)
                .setRegisteredUserProtocol(BusinessProtocolMessages.RegisteredUserProtocol.newBuilder()
                        .setRegisteredUser(userDto.toProtobuf())
                        .build())
                .build();
    }

    // 游客登录
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onLoginAsTouristsSender() {
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.LOGIN_TOURISTS)
                .setFromId(DeviceUtils.getDeviceId(App.getContext()))
                .setToId(IMSContacts.ToId.LOGIN)
                .setTimestamp(System.currentTimeMillis())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.LoginProtocol)
                .setLoginProtocol(BusinessProtocolMessages.LoginProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .build())
                .build();
    }

    // 注册用户登录
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onLoginAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        RegisteredUserDto userDto = Dto.fromJson(params, RegisteredUserDto.class);
        if (null == userDto) return null;
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.LOGIN_REGISTERED)
                .setFromId(DeviceUtils.getDeviceId(App.getContext()))
                .setToId(IMSContacts.ToId.LOGIN)
                .setTimestamp(System.currentTimeMillis())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.LoginProtocol)
                .setLoginProtocol(BusinessProtocolMessages.LoginProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(userDto.toProtobuf())
                        .build())
                .build();
    }

    // 游客登出
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onLogoutAsTouristsSender() {
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.LOGOUT_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.ToId.LOGOUT)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.LogoutProtocol)
                .setLogoutProtocol(BusinessProtocolMessages.LogoutProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .build())
                .build();
    }

    // 注册用户登出
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onLogoutAsRegisteredSender() {
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.LOGOUT_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.ToId.LOGOUT)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.LogoutProtocol)
                .setLogoutProtocol(BusinessProtocolMessages.LogoutProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .build())
                .build();
    }

    // 查找好友(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendFindAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        SearchDto searchDto = Dto.fromJson(params, SearchDto.class);
        if (null == searchDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_FIND_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FindUserProtocol)
                .setFindUserProtocol(BusinessProtocolMessages.FindUserProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setSearch(searchDto.toProtobuf())
                        .build())
                .build();
    }

    // 查找好友(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendFindAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        SearchDto searchDto = Dto.fromJson(params, SearchDto.class);
        if (null == searchDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_FIND_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FindUserProtocol)
                .setFindUserProtocol(BusinessProtocolMessages.FindUserProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setSearch(searchDto.toProtobuf())
                        .build())
                .build();
    }

    // 获取好友列表(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendListAsTouristsSender() {
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_LIST_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendListProtocol)
                .setFriendListProtocol(BusinessProtocolMessages.FriendListProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .build())
                .build();
    }

    // 获取好友列表(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendListAsRegisteredSender() {
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_LIST_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendListProtocol)
                .setFriendListProtocol(BusinessProtocolMessages.FriendListProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .build())
                .build();
    }

    // 好友资料(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendInfoAsTouristsSender(String friendId) {
        String userId = UserPreferences.getUserId();
        if (TextUtils.isEmpty(friendId)) return null;
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_INFO_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendInfoProtocol)
                .setFriendInfoProtocol(BusinessProtocolMessages.FriendInfoProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsFriend(BusinessProtocolEntities.TouristsFriend.newBuilder().setFriendId(friendId).build())
                        .build())
                .build();
    }

    // 好友资料(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendInfoAsRegisteredSender(String friendId) {
        String userId = UserPreferences.getUserId();
        if (TextUtils.isEmpty(friendId)) return null;
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_INFO_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendInfoProtocol)
                .setFriendInfoProtocol(BusinessProtocolMessages.FriendInfoProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredFriend(BusinessProtocolEntities.RegisteredFriend.newBuilder().setFriendId(friendId).build())
                        .build())
                .build();
    }

    // 更新好友在线状态(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendOnlineStatusChangeAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        FriendDto friendDto = Dto.fromJson(params, FriendDto.class);
        if (null == friendDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_ONLINE_STATUS_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendOnlineStatusChangeProtocol)
                .setFriendOnlineStatusChangeProtocol(BusinessProtocolMessages.FriendOnlineStatusChangeProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsFriend((BusinessProtocolEntities.TouristsFriend) friendDto.toProtobuf())
                        .build())
                .build();
    }

    // 更新好友在线状态(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendOnlineStatusChangeAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        FriendDto friendDto = Dto.fromJson(params, FriendDto.class);
        if (null == friendDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_ONLINE_STATUS_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendOnlineStatusChangeProtocol)
                .setFriendOnlineStatusChangeProtocol(BusinessProtocolMessages.FriendOnlineStatusChangeProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredFriend((BusinessProtocolEntities.RegisteredFriend) friendDto.toProtobuf())
                        .build())
                .build();
    }

    // 申请加好友(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendApplyAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        ChatFriendMsgDto friendDto = Dto.fromJson(params, ChatFriendMsgDto.class);
        if (null == friendDto || null == friendDto.getFriendDto()) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_APPLY_TOURISTS)
                .setFromId(userId)
                .setToId(friendDto.getFriendDto().getFriendUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendChatProtocol)
                .setFriendChatProtocol(friendDto.toProtobuf())
                .build();
    }

    // 申请加好友(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendApplyAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        ChatFriendMsgDto friendDto = Dto.fromJson(params, ChatFriendMsgDto.class);
        if (null == friendDto || null == friendDto.getFriendDto()) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_APPLY_REGISTERED)
                .setFromId(userId)
                .setToId(friendDto.getFriendDto().getFriendUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendChatProtocol)
                .setFriendChatProtocol(friendDto.toProtobuf())
                .build();
    }

    // 同意好友申请(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendApplyAgreeAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        FriendDto friendDto = Dto.fromJson(params, FriendDto.class);
        if (null == friendDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_APPLY_AGREE_TOURISTS)
                .setFromId(userId)
                .setToId(friendDto.getFriendUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        String nickName = UserPreferences.getNickname();
        String avatar = UserPreferences.getAvatar();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendAddProtocol)
                .setFriendAddProtocol(BusinessProtocolMessages.FriendAddProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder()
                                .setTemporaryId(userId)
                                .setNickname(nickName)
                                .setAvatar(avatar)
                                .build())
                        .addTouristsFriend((BusinessProtocolEntities.TouristsFriend) friendDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.AGREE)
                        .build())
                .build();
    }

    // 同意好友申请(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendApplyAgreeAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        FriendDto friendDto = Dto.fromJson(params, FriendDto.class);
        if (null == friendDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_APPLY_AGREE_REGISTERED)
                .setFromId(userId)
                .setToId(friendDto.getFriendUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        String nickName = UserPreferences.getNickname();
        String avatar = UserPreferences.getAvatar();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendAddProtocol)
                .setFriendAddProtocol(BusinessProtocolMessages.FriendAddProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder()
                                .setUserId(userId)
                                .setNickname(nickName)
                                .setAvatar(avatar)
                                .build())
                        .addRegisteredFriend((BusinessProtocolEntities.RegisteredFriend) friendDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.AGREE)
                        .build())
                .build();
    }

    // 拒绝好友申请(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendApplyRefuseAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        ChatFriendMsgDto friendDto = Dto.fromJson(params, ChatFriendMsgDto.class);
        if (null == friendDto || null == friendDto.getFriendDto()) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_APPLY_REFUSE_TOURISTS)
                .setFromId(userId)
                .setToId(friendDto.getFriendDto().getFriendUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendChatProtocol)
                .setFriendChatProtocol(friendDto.toProtobuf())
                .build();
    }

    // 拒绝好友申请(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendApplyRefuseAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        ChatFriendMsgDto friendDto = Dto.fromJson(params, ChatFriendMsgDto.class);
        if (null == friendDto || null == friendDto.getFriendDto()) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_APPLY_REFUSE_REGISTERED)
                .setFromId(userId)
                .setToId(friendDto.getFriendDto().getFriendUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendChatProtocol)
                .setFriendChatProtocol(friendDto.toProtobuf())
                .build();
    }

    // 删除好友(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendDeleteAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        FriendDto friendDto = Dto.fromJson(params, FriendDto.class);
        if (null == friendDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_DELETE_TOURISTS)
                .setFromId(userId)
                .setToId(friendDto.getFriendUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendDeleteProtocol)
                .setFriendDeleteProtocol(BusinessProtocolMessages.FriendDeleteProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsFriend((BusinessProtocolEntities.TouristsFriend) friendDto.toProtobuf())
                        .build())
                .build();
    }

    // 删除好友(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendDeleteAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        FriendDto friendDto = Dto.fromJson(params, FriendDto.class);
        if (null == friendDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_DELETE_REGISTERED)
                .setFromId(userId)
                .setToId(friendDto.getFriendUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendDeleteProtocol)
                .setFriendDeleteProtocol(BusinessProtocolMessages.FriendDeleteProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredFriend((BusinessProtocolEntities.RegisteredFriend) friendDto.toProtobuf())
                        .build())
                .build();
    }

    // 查找群组(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupFindAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        SearchDto searchDto = Dto.fromJson(params, SearchDto.class);
        if (null == searchDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_FIND_NEW)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FindGroupProtocol)
                .setFindGroupProtocol(BusinessProtocolMessages.FindGroupProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setSearch(searchDto.toProtobuf())
                        .build())
                .build();
    }

    // 查找群组(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupFindAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        SearchDto searchDto = Dto.fromJson(params, SearchDto.class);
        if (null == searchDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_FIND_NEW)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FindGroupProtocol)
                .setFindGroupProtocol(BusinessProtocolMessages.FindGroupProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setSearch(searchDto.toProtobuf())
                        .build())
                .build();
    }

    // 获取群组列表(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupListAsTouristsSender() {
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_LIST_NEW)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupListProtocol)
                .setGroupListProtocol(BusinessProtocolMessages.GroupListProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .build())
                .build();
    }

    // 获取群组列表(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupListAsRegisteredSender() {
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_LIST_NEW)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupListProtocol)
                .setGroupListProtocol(BusinessProtocolMessages.GroupListProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .build())
                .build();
    }

    // 创建群(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupCreateAsTouristsSender(String friendUserIds) {
        if (TextUtils.isEmpty(friendUserIds)) return null;
        String userId = UserPreferences.getUserId();
        String userName = UserPreferences.getNickname();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_CREATE_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupCreateProtocol)
                .setGroupCreateProtocol(BusinessProtocolMessages.GroupCreateProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder()
                                .setTemporaryId(userId)
                                .setNickname(friendUserIds)
                                .setAvatar(userName)
                                .build())
                        .build())
                .build();
    }

    // 创建群(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupCreateAsRegisteredSender(String friendUserIds) {
        if (TextUtils.isEmpty(friendUserIds)) return null;
        String userId = UserPreferences.getUserId();
        String userName = UserPreferences.getNickname();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_CREATE_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupCreateProtocol)
                .setGroupCreateProtocol(BusinessProtocolMessages.GroupCreateProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder()
                                .setUserId(userId)
                                .setNickname(friendUserIds)
                                .setAvatar(userName)
                                .build())
                        .build())
                .build();
    }

    // 群资料(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupInfoAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        String groupId;
        String token;
        try {
            String[] split = params.split(";");
            groupId = split[0];
            token = split[1];
        } catch (Exception e) {
            return null;
        }

        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_INFO_NEW)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(token)
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupInfoProtocol)
                .setGroupInfoProtocol(BusinessProtocolMessages.GroupInfoProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsGroup(BusinessProtocolEntities.TouristsGroup.newBuilder().setGroupId(groupId).build())
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredGroup(BusinessProtocolEntities.RegisteredGroup.newBuilder().setGroupId(groupId).build())
                        .build())
                .build();
    }

    // 群资料(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupInfoAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        String groupId;
        String token;
        try {
            String[] split = params.split(";");
            groupId = split[0];
            token = split[1];
        } catch (Exception e) {
            return null;
        }

        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_INFO_NEW)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(token)
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupInfoProtocol)
                .setGroupInfoProtocol(BusinessProtocolMessages.GroupInfoProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsGroup(BusinessProtocolEntities.TouristsGroup.newBuilder().setGroupId(groupId).build())
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredGroup(BusinessProtocolEntities.RegisteredGroup.newBuilder().setGroupId(groupId).build())
                        .build())
                .build();
    }

    // 更新群成员在线状态(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberOnlineStatusChangeAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupMemberDto groupMemberDto = Dto.fromJson(params, GroupMemberDto.class);
        if (null == groupMemberDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_ONLINE_STATUS_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupMemberOnlineStatusChangeProtocol)
                .setGroupMemberOnlineStatusChangeProtocol(BusinessProtocolMessages.GroupMemberOnlineStatusChangeProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsGroupMember((BusinessProtocolEntities.TouristsGroupMember) groupMemberDto.toProtobuf())
                        .build())
                .build();
    }

    // 更新群成员在线状态(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberOnlineStatusChangeAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupMemberDto groupMemberDto = Dto.fromJson(params, GroupMemberDto.class);
        if (null == groupMemberDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_ONLINE_STATUS_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupMemberOnlineStatusChangeProtocol)
                .setGroupMemberOnlineStatusChangeProtocol(BusinessProtocolMessages.GroupMemberOnlineStatusChangeProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredGroupMember((BusinessProtocolEntities.RegisteredGroupMember) groupMemberDto.toProtobuf())
                        .build())
                .build();
    }

    // 邀请入群(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberInviteAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        InviteDto inviteDto = Dto.fromJson(params, InviteDto.class);
        if (inviteDto == null) return null;
        String userId = UserPreferences.getUserId();
        int groupIdInt;
        int userIdInt;
        try {
            groupIdInt = Integer.parseInt(inviteDto.getGroupId());
            userIdInt = Integer.parseInt(userId);
        } catch (NumberFormatException e) {
            return null;
        }
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_INVITE_TOURISTS)
                .setFromId(userId)
                .setToId(inviteDto.getGroupId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupMemberAddProtocol)
                .setGroupMemberAddProtocol(BusinessProtocolMessages.GroupMemberAddProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder()
                                .setTemporaryId(userId)
                                .setNickname(inviteDto.getUserIds())
                                .build())
                        .setTouristsGroupMember(BusinessProtocolEntities.TouristsGroupMember.newBuilder()
                                .setGroup(BusinessProtocolEntities.TouristsGroup.newBuilder()
                                        .setGroupId(inviteDto.getGroupId()).build())
                                .build())
                        .addAllGroupMemberVo(BusinessProtocolEntities.AllGroupMemberVO.newBuilder()
                                .setRegisteredUserId(userIdInt)
                                .setRegisteredGroupId(groupIdInt)
                                .setGroupRemarks(inviteDto.getUserIds())
                                .build())
                        .setAddType(IMSContacts.Type.INVITE)
                        .setOperation(IMSContacts.Operation.APPLY)
                        .build())
                .build();
    }

    // 邀请入群(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberInviteAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        InviteDto inviteDto = Dto.fromJson(params, InviteDto.class);
        if (inviteDto == null) return null;
        String userId = UserPreferences.getUserId();
        int groupIdInt;
        int userIdInt;
        try {
            groupIdInt = Integer.parseInt(inviteDto.getGroupId());
            userIdInt = Integer.parseInt(userId);
        } catch (NumberFormatException e) {
            return null;
        }
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_INVITE_REGISTERED)
                .setFromId(userId)
                .setToId(inviteDto.getGroupId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupMemberAddProtocol)
                .setGroupMemberAddProtocol(BusinessProtocolMessages.GroupMemberAddProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder()
                                .setUserId(userId)
                                .setNickname(inviteDto.getUserIds())
                                .build())
                        .setRegisteredGroupMember(BusinessProtocolEntities.RegisteredGroupMember.newBuilder()
                                .setGroup(BusinessProtocolEntities.RegisteredGroup.newBuilder()
                                        .setGroupId(inviteDto.getGroupId()).build())
                                .build())
                        .addAllGroupMemberVo(BusinessProtocolEntities.AllGroupMemberVO.newBuilder()
                                .setRegisteredUserId(userIdInt)
                                .setRegisteredGroupId(groupIdInt)
                                .setGroupRemarks(inviteDto.getUserIds())
                                .build())
                        .setAddType(IMSContacts.Type.INVITE)
                        .setOperation(IMSContacts.Operation.APPLY)
                        .build())
                .build();
    }

    // 同意邀请(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberInviteAgreeAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupMemberDto groupMemberDto = Dto.fromJson(params, GroupMemberDto.class);
        if (null == groupMemberDto || null == groupMemberDto.getGroup()) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_INVITE_AGREE_TOURISTS)
                .setFromId(userId)
                .setToId(groupMemberDto.getGroup().getGroupId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupMemberAddProtocol)
                .setGroupMemberAddProtocol(BusinessProtocolMessages.GroupMemberAddProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsGroupMember((BusinessProtocolEntities.TouristsGroupMember) groupMemberDto.toProtobuf())
                        .setAddType(IMSContacts.Type.INVITE)
                        .setOperation(IMSContacts.Operation.AGREE)
                        .build())
                .build();
    }

    // 同意邀请(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberInviteAgreeAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupMemberDto groupMemberDto = Dto.fromJson(params, GroupMemberDto.class);
        if (null == groupMemberDto || null == groupMemberDto.getGroup()) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_INVITE_AGREE_REGISTERED)
                .setFromId(userId)
                .setToId(groupMemberDto.getGroup().getGroupId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupMemberAddProtocol)
                .setGroupMemberAddProtocol(BusinessProtocolMessages.GroupMemberAddProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredGroupMember((BusinessProtocolEntities.RegisteredGroupMember) groupMemberDto.toProtobuf())
                        .setAddType(IMSContacts.Type.INVITE)
                        .setOperation(IMSContacts.Operation.AGREE)
                        .build())
                .build();
    }

    // 拒绝邀请(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberInviteRefuseAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupMemberDto groupMemberDto = Dto.fromJson(params, GroupMemberDto.class);
        if (null == groupMemberDto || null == groupMemberDto.getGroup()) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_INVITE_REFUSE_TOURISTS)
                .setFromId(userId)
                .setToId(groupMemberDto.getGroupMemberUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupMemberAddProtocol)
                .setGroupMemberAddProtocol(BusinessProtocolMessages.GroupMemberAddProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsGroupMember((BusinessProtocolEntities.TouristsGroupMember) groupMemberDto.toProtobuf())
                        .setAddType(IMSContacts.Type.INVITE)
                        .setOperation(IMSContacts.Operation.REFUSE)
                        .build())
                .build();
    }

    // 拒绝邀请(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberInviteRefuseAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupMemberDto groupMemberDto = Dto.fromJson(params, GroupMemberDto.class);
        if (null == groupMemberDto || null == groupMemberDto.getGroup()) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_INVITE_REFUSE_REGISTERED)
                .setFromId(userId)
                .setToId(groupMemberDto.getGroupMemberUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupMemberAddProtocol)
                .setGroupMemberAddProtocol(BusinessProtocolMessages.GroupMemberAddProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredGroupMember((BusinessProtocolEntities.RegisteredGroupMember) groupMemberDto.toProtobuf())
                        .setAddType(IMSContacts.Type.INVITE)
                        .setOperation(IMSContacts.Operation.REFUSE)
                        .build())
                .build();
    }

    // 申请入群(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberApplyAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        ChatGroupMsgDto groupChatMsgDto = Dto.fromJson(params, ChatGroupMsgDto.class);
        if (null == groupChatMsgDto || null == groupChatMsgDto.getGroupMemberDto() || null == groupChatMsgDto.getGroupMemberDto().getGroup() || null == groupChatMsgDto.getChatMessageDto())
            return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_APPLY_TOURISTS)
                .setFromId(userId)
                .setToId(groupChatMsgDto.getGroupMemberDto().getGroup().getGroupOwnerUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupChatProtocol)
                .setGroupChatProtocol(groupChatMsgDto.toProtobuf())
                .build();
    }

    // 申请入群(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberApplyAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        ChatGroupMsgDto groupChatMsgDto = Dto.fromJson(params, ChatGroupMsgDto.class);
        if (null == groupChatMsgDto || null == groupChatMsgDto.getGroupMemberDto() || null == groupChatMsgDto.getGroupMemberDto().getGroup() || null == groupChatMsgDto.getChatMessageDto())
            return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_APPLY_REGISTERED)
                .setFromId(userId)
                .setToId(groupChatMsgDto.getGroupMemberDto().getGroup().getGroupOwnerUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupChatProtocol)
                .setGroupChatProtocol(groupChatMsgDto.toProtobuf())
                .build();
    }

    // 同意申请(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberApplyAgreeAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupMemberDto groupMemberDto = Dto.fromJson(params, GroupMemberDto.class);
        if (null == groupMemberDto || null == groupMemberDto.getGroup()) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_APPLY_AGREE_TOURISTS)
                .setFromId(userId)
                .setToId(groupMemberDto.getGroupMemberUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupMemberAddProtocol)
                .setGroupMemberAddProtocol(BusinessProtocolMessages.GroupMemberAddProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsGroupMember((BusinessProtocolEntities.TouristsGroupMember) groupMemberDto.toProtobuf())
                        .setAddType(IMSContacts.Type.APPLY)
                        .setOperation(IMSContacts.Operation.AGREE)
                        .build())
                .build();
    }

    // 同意申请(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberApplyAgreeAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupMemberDto groupMemberDto = Dto.fromJson(params, GroupMemberDto.class);
        if (null == groupMemberDto || null == groupMemberDto.getGroup()) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_APPLY_AGREE_REGISTERED)
                .setFromId(userId)
                .setToId(groupMemberDto.getGroupMemberUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupMemberAddProtocol)
                .setGroupMemberAddProtocol(BusinessProtocolMessages.GroupMemberAddProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredGroupMember((BusinessProtocolEntities.RegisteredGroupMember) groupMemberDto.toProtobuf())
                        .setAddType(IMSContacts.Type.APPLY)
                        .setOperation(IMSContacts.Operation.AGREE)
                        .build())
                .build();
    }

    // 拒绝申请(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberApplyRefuseAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        ChatGroupMsgDto groupChatMsgDto = Dto.fromJson(params, ChatGroupMsgDto.class);
        if (null == groupChatMsgDto || null == groupChatMsgDto.getGroupMemberDto() || null == groupChatMsgDto.getGroupMemberDto().getGroup() || null == groupChatMsgDto.getChatMessageDto())
            return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_APPLY_REFUSE_TOURISTS)
                .setFromId(userId)
                .setToId(groupChatMsgDto.getGroupMemberDto().getGroup().getGroupOwnerUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        groupChatMsgDto.getGroupMemberDto().getGroup().setGroupOwnerUserId(null);
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupChatProtocol)
                .setGroupChatProtocol(groupChatMsgDto.toProtobuf())
                .build();
    }

    // 拒绝申请(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberApplyRefuseAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        ChatGroupMsgDto groupChatMsgDto = Dto.fromJson(params, ChatGroupMsgDto.class);
        if (null == groupChatMsgDto || null == groupChatMsgDto.getGroupMemberDto() || null == groupChatMsgDto.getGroupMemberDto().getGroup() || null == groupChatMsgDto.getChatMessageDto())
            return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_APPLY_REFUSE_REGISTERED)
                .setFromId(userId)
                .setToId(groupChatMsgDto.getGroupMemberDto().getGroup().getGroupOwnerUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        groupChatMsgDto.getGroupMemberDto().getGroup().setGroupOwnerUserId(null);
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupChatProtocol)
                .setGroupChatProtocol(groupChatMsgDto.toProtobuf())
                .build();
    }

    // 删除群成员
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberDeleteSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        ChatGroupMsgDto groupChatMsgDto = Dto.fromJson(params, ChatGroupMsgDto.class);
        if (null == groupChatMsgDto || null == groupChatMsgDto.getGroupMemberDto() || null == groupChatMsgDto.getGroupMemberDto().getGroup() || null == groupChatMsgDto.getChatMessageDto())
            return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_DELETE)
                .setFromId(userId)
                .setToId(groupChatMsgDto.getGroupMemberDto().getGroup().getGroupId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        groupChatMsgDto.getGroupMemberDto().getGroup().setGroupOwnerUserId(null);
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupChatProtocol)
                .setGroupChatProtocol(groupChatMsgDto.toProtobuf())
                .build();
    }

    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberExitSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        ChatGroupMsgDto groupChatMsgDto = Dto.fromJson(params, ChatGroupMsgDto.class);
        if (null == groupChatMsgDto || null == groupChatMsgDto.getGroupMemberDto() || null == groupChatMsgDto.getGroupMemberDto().getGroup() || null == groupChatMsgDto.getChatMessageDto())
            return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_EXIT)
                .setFromId(userId)
                .setToId(groupChatMsgDto.getGroupMemberDto().getGroup().getGroupId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        groupChatMsgDto.getGroupMemberDto().getGroup().setGroupOwnerUserId(null);
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupChatProtocol)
                .setGroupChatProtocol(groupChatMsgDto.toProtobuf())
                .build();
    }

    // 删除群成员(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberDeleteAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupMemberDto groupMemberDto = Dto.fromJson(params, GroupMemberDto.class);
        if (null == groupMemberDto || null == groupMemberDto.getGroup()) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_DELETE_TOURISTS)
                .setFromId(userId)
                .setToId(groupMemberDto.getGroupMemberUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupMemberDeleteProtocol)
                .setGroupMemberDeleteProtocol(BusinessProtocolMessages.GroupMemberDeleteProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsGroupMember((BusinessProtocolEntities.TouristsGroupMember) groupMemberDto.toProtobuf())
                        .build())
                .build();
    }

    // 删除群成员(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberDeleteAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupMemberDto groupMemberDto = Dto.fromJson(params, GroupMemberDto.class);
        if (null == groupMemberDto || null == groupMemberDto.getGroup()) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_DELETE_REGISTERED)
                .setFromId(userId)
                .setToId(groupMemberDto.getGroupMemberUserId())
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupMemberDeleteProtocol)
                .setGroupMemberDeleteProtocol(BusinessProtocolMessages.GroupMemberDeleteProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredGroupMember((BusinessProtocolEntities.RegisteredGroupMember) groupMemberDto.toProtobuf())
                        .build())
                .build();
    }

    // 修改群公告(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupAnnouncementUpdateAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupDto groupDto = Dto.fromJson(params, GroupDto.class);
        if (null == groupDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_ANNOUNCEMENT_UPDATE_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupAnnouncementProtocol)
                .setGroupAnnouncementProtocol(BusinessProtocolMessages.GroupAnnouncementProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsGroup((BusinessProtocolEntities.TouristsGroup) groupDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.EDIT_GROUP_ANNOUNCEMENT)
                        .build())
                .build();
    }

    // 修改群公告(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupAnnouncementUpdateAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupDto groupDto = Dto.fromJson(params, GroupDto.class);
        if (null == groupDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_ANNOUNCEMENT_UPDATE_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupAnnouncementProtocol)
                .setGroupAnnouncementProtocol(BusinessProtocolMessages.GroupAnnouncementProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredGroup((BusinessProtocolEntities.RegisteredGroup) groupDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.EDIT_GROUP_ANNOUNCEMENT)
                        .build())
                .build();
    }

    // 设置昵称(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalNicknameAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        TouristsUserDto touristsUserDto = Dto.fromJson(params, TouristsUserDto.class);
        if (null == touristsUserDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_NICKNAME_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalInfoProtocol)
                .setPersonalInfoProtocol(BusinessProtocolMessages.PersonalInfoProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setSettingsTouristsUser(touristsUserDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SETTINGS_NICK)
                        .build())
                .build();
    }

    // 设置昵称(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalNicknameAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        RegisteredUserDto registeredUserDto = Dto.fromJson(params, RegisteredUserDto.class);
        if (null == registeredUserDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_NICKNAME_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalInfoProtocol)
                .setPersonalInfoProtocol(BusinessProtocolMessages.PersonalInfoProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setSettingsRegisteredUser(registeredUserDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SETTINGS_NICK)
                        .build())
                .build();
    }

    // 设置头像(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalAvatarAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        TouristsUserDto touristsUserDto = Dto.fromJson(params, TouristsUserDto.class);
        if (null == touristsUserDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_AVATAR_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalInfoProtocol)
                .setPersonalInfoProtocol(BusinessProtocolMessages.PersonalInfoProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setSettingsTouristsUser(touristsUserDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SETTINGS_AVATAR)
                        .build())
                .build();
    }

    // 设置头像(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalAvatarAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        RegisteredUserDto registeredUserDto = Dto.fromJson(params, RegisteredUserDto.class);
        if (null == registeredUserDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_AVATAR_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalInfoProtocol)
                .setPersonalInfoProtocol(BusinessProtocolMessages.PersonalInfoProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setSettingsRegisteredUser(registeredUserDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SETTINGS_AVATAR)
                        .build())
                .build();
    }

    // 获取验证码
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalVerificationCodeSender(String phone) {
        if (TextUtils.isEmpty(phone)) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.VERIFICATION_CODE)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalInfoProtocol)
                .setPersonalInfoProtocol(BusinessProtocolMessages.PersonalInfoProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setSettingsRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).setPhone(phone).build())
                        .setOperation(IMSContacts.Operation.SETTINGS_VERIFY_CODE)
                        .build())
                .build();
    }

    // 获取验证码
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onNotLoginVerificationCodeSender(String phone) {
        if (TextUtils.isEmpty(phone)) return null;
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.VERIFICATION_CODE)
                .setFromId(DeviceUtils.getDeviceId(App.getContext()))
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalInfoProtocol)
                .setPersonalInfoProtocol(BusinessProtocolMessages.PersonalInfoProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setSettingsRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setPhone(phone).build())
                        .setOperation(IMSContacts.Operation.SETTINGS_VERIFY_CODE)
                        .build())
                .build();
    }

    // 重置密码-验证
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalResetSecretVerifySender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        RegisteredUserDto registeredUserDto = Dto.fromJson(params, RegisteredUserDto.class);
        if (null == registeredUserDto) return null;
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.RESET_SECRET_VERIFY)
                .setFromId(DeviceUtils.getDeviceId(App.getContext()))
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalInfoProtocol)
                .setPersonalInfoProtocol(BusinessProtocolMessages.PersonalInfoProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(registeredUserDto.getUserId()).build())
                        .setSettingsRegisteredUser(registeredUserDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.RESET_SECRET_VERIFY)
                        .build())
                .build();
    }

    // 重置密码-重置
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalResetSecretSender(String newSecret) {
        if (TextUtils.isEmpty(newSecret)) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.RESET_SECRET)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalInfoProtocol)
                .setPersonalInfoProtocol(BusinessProtocolMessages.PersonalInfoProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setSettingsRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).setSecret(newSecret).build())
                        .setOperation(IMSContacts.Operation.RESET_SECRET)
                        .build())
                .build();
    }

    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onNotLoginResetSecretSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        RegisteredUserDto registeredUserDto = Dto.fromJson(params, RegisteredUserDto.class);
        if (registeredUserDto == null) return null;
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.RESET_SECRET)
                .setFromId(DeviceUtils.getDeviceId(App.getContext()))
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalInfoProtocol)
                .setPersonalInfoProtocol(BusinessProtocolMessages.PersonalInfoProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(registeredUserDto.getUserId()).build())
                        .setSettingsRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(registeredUserDto.getUserId()).setSecret(registeredUserDto.getSecret()).build())
                        .setOperation(IMSContacts.Operation.RESET_SECRET)
                        .build())
                .build();
    }

    // 设置手机
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalSetupPhoneSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        RegisteredUserDto registeredUserDto = Dto.fromJson(params, RegisteredUserDto.class);
        if (null == registeredUserDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.SETUP_PHONE)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalInfoProtocol)
                .setPersonalInfoProtocol(BusinessProtocolMessages.PersonalInfoProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setSettingsRegisteredUser(registeredUserDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SETTINGS_PHONE)
                        .build())
                .build();
    }

    // 修改手机
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalEditPhoneSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        RegisteredUserSettingsDto registeredUserDto = Dto.fromJson(params, RegisteredUserSettingsDto.class);
        if (null == registeredUserDto || null == registeredUserDto.getRegisteredUserDto() || null == registeredUserDto.getSettingsUserDto())
            return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.SETUP_PHONE_EDIT)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalInfoProtocol)
                .setPersonalInfoProtocol(BusinessProtocolMessages.PersonalInfoProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(registeredUserDto.getRegisteredUserDto().toProtobuf())
                        .setSettingsRegisteredUser(registeredUserDto.getSettingsUserDto().toProtobuf())
                        .setOperation(IMSContacts.Operation.UPDATE_PHONE)
                        .build())
                .build();
    }

    // 设置-是否接收离线消息(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalOfflineMsgAsTouristsSender(String params) {
        boolean isOfflineMsg;
        try {
            isOfflineMsg = Boolean.parseBoolean(params);
        } catch (Exception e) {
            return null;
        }
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_OFFLINE_MSG_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalSettingsProtocol)
                .setPersonalSettingsProtocol(BusinessProtocolMessages.PersonalSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setSettings(BusinessProtocolEntities.Settings.newBuilder().setOfflineMessage(isOfflineMsg).build())
                        .setOperation(IMSContacts.Operation.OFFLINE_MESSAGE)
                        .build())
                .build();
    }

    // 设置-是否接收离线消息(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalOfflineMsgAsRegisteredSender(String params) {
        boolean isOfflineMsg;
        try {
            isOfflineMsg = Boolean.parseBoolean(params);
        } catch (Exception e) {
            return null;
        }
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_OFFLINE_MSG_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalSettingsProtocol)
                .setPersonalSettingsProtocol(BusinessProtocolMessages.PersonalSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setSettings(BusinessProtocolEntities.Settings.newBuilder().setOfflineMessage(isOfflineMsg).build())
                        .setOperation(IMSContacts.Operation.OFFLINE_MESSAGE)
                        .build())
                .build();
    }

    // 设置-好友阅后即焚(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalFriendSnapchatAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        SettingsDto settingsDto = Dto.fromJson(params, SettingsDto.class);
        if (null == settingsDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_FRIEND_SNAPCHAT_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalSettingsProtocol)
                .setPersonalSettingsProtocol(BusinessProtocolMessages.PersonalSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setSettings(settingsDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SNAPCHAT_STATUS_FRIEND)
                        .build())
                .build();
    }

    // 设置-好友阅后即焚(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalFriendSnapchatAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        SettingsDto settingsDto = Dto.fromJson(params, SettingsDto.class);
        if (null == settingsDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_FRIEND_SNAPCHAT_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalSettingsProtocol)
                .setPersonalSettingsProtocol(BusinessProtocolMessages.PersonalSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setSettings(settingsDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SNAPCHAT_STATUS_FRIEND)
                        .build())
                .build();
    }

    // 设置-好友阅后即焚时长(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalFriendSnapchatLengthAsTouristsSender(String params) {
        int snapchatLength;
        try {
            snapchatLength = Integer.parseInt(params);
        } catch (NumberFormatException e) {
            return null;
        }
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_FRIEND_SNAPCHAT_LENGTH_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalSettingsProtocol)
                .setPersonalSettingsProtocol(BusinessProtocolMessages.PersonalSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setSettings(BusinessProtocolEntities.Settings.newBuilder().setSnapchatTimeLength(snapchatLength).build())
                        .setOperation(IMSContacts.Operation.SNAPCHAT_LENGTH_FRIEND)
                        .build())
                .build();
    }

    // 设置-好友阅后即焚时长(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalFriendSnapchatLengthAsRegisteredSender(String params) {
        int snapchatLength;
        try {
            snapchatLength = Integer.parseInt(params);
        } catch (NumberFormatException e) {
            return null;
        }
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_FRIEND_SNAPCHAT_LENGTH_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalSettingsProtocol)
                .setPersonalSettingsProtocol(BusinessProtocolMessages.PersonalSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setSettings(BusinessProtocolEntities.Settings.newBuilder().setSnapchatTimeLength(snapchatLength).build())
                        .setOperation(IMSContacts.Operation.SNAPCHAT_LENGTH_FRIEND)
                        .build())
                .build();
    }

    // 设置-群阅后即焚开关(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalGroupSnapchatAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        SettingsDto settingsDto = Dto.fromJson(params, SettingsDto.class);
        if (null == settingsDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_GROUP_SNAPCHAT_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalSettingsProtocol)
                .setPersonalSettingsProtocol(BusinessProtocolMessages.PersonalSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setSettings(settingsDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SNAPCHAT_STATUS_GROUP)
                        .build())
                .build();
    }

    // 设置-群阅后即焚开关(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalGroupSnapchatAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        SettingsDto settingsDto = Dto.fromJson(params, SettingsDto.class);
        if (null == settingsDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_GROUP_SNAPCHAT_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalSettingsProtocol)
                .setPersonalSettingsProtocol(BusinessProtocolMessages.PersonalSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setSettings(settingsDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SNAPCHAT_STATUS_GROUP)
                        .build())
                .build();
    }

    // 设置-群阅后即焚时长(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalGroupSnapchatLengthAsTouristsSender(String params) {
        int snapchatLength;
        try {
            snapchatLength = Integer.parseInt(params);
        } catch (NumberFormatException e) {
            return null;
        }
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_GROUP_SNAPCHAT_LENGTH_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalSettingsProtocol)
                .setPersonalSettingsProtocol(BusinessProtocolMessages.PersonalSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setSettings(BusinessProtocolEntities.Settings.newBuilder().setSnapchatTimeLength(snapchatLength).build())
                        .setOperation(IMSContacts.Operation.SNAPCHAT_LENGTH_GROUP)
                        .build())
                .build();
    }

    // 设置-群阅后即焚时长(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalGroupSnapchatLengthAsRegisteredSender(String params) {
        int snapchatLength;
        try {
            snapchatLength = Integer.parseInt(params);
        } catch (NumberFormatException e) {
            return null;
        }
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_GROUP_SNAPCHAT_LENGTH_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalSettingsProtocol)
                .setPersonalSettingsProtocol(BusinessProtocolMessages.PersonalSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setSettings(BusinessProtocolEntities.Settings.newBuilder().setSnapchatTimeLength(snapchatLength).build())
                        .setOperation(IMSContacts.Operation.SNAPCHAT_LENGTH_GROUP)
                        .build())
                .build();
    }

    // 设置-是否每次退出清理(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalExitCleanAsTouristsSender(String params) {
        boolean isExitClean;
        try {
            isExitClean = Boolean.parseBoolean(params);
        } catch (Exception e) {
            return null;
        }
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_EXIT_CLEAN_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalSettingsProtocol)
                .setPersonalSettingsProtocol(BusinessProtocolMessages.PersonalSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setSettings(BusinessProtocolEntities.Settings.newBuilder().setExitClean(isExitClean).build())
                        .setOperation(IMSContacts.Operation.SETTINGS_EXIT_CLEAN)
                        .build())
                .build();
    }

    // 设置-是否每次退出清理(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalExitCleanAsRegisteredSender(String params) {
        boolean isExitClean;
        try {
            isExitClean = Boolean.parseBoolean(params);
        } catch (Exception e) {
            return null;
        }
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_EXIT_CLEAN_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalSettingsProtocol)
                .setPersonalSettingsProtocol(BusinessProtocolMessages.PersonalSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setSettings(BusinessProtocolEntities.Settings.newBuilder().setExitClean(isExitClean).build())
                        .setOperation(IMSContacts.Operation.SETTINGS_EXIT_CLEAN)
                        .build())
                .build();
    }

    // 设置-定期清理周期(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalTimerCleanAsTouristsSender(String params) {
        int timerStage;
        try {
            timerStage = Integer.parseInt(params);
        } catch (NumberFormatException e) {
            return null;
        }
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_TIMER_CLEAN_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalSettingsProtocol)
                .setPersonalSettingsProtocol(BusinessProtocolMessages.PersonalSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setSettings(BusinessProtocolEntities.Settings.newBuilder().setTimerClean(timerStage).build())
                        .setOperation(IMSContacts.Operation.SETTINGS_TIMER_CLEAN)
                        .build())
                .build();
    }

    // 设置-定期清理周期(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalTimerCleanAsRegisteredSender(String params) {
        int timerStage;
        try {
            timerStage = Integer.parseInt(params);
        } catch (NumberFormatException e) {
            return null;
        }
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_TIMER_CLEAN_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalSettingsProtocol)
                .setPersonalSettingsProtocol(BusinessProtocolMessages.PersonalSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setSettings(BusinessProtocolEntities.Settings.newBuilder().setTimerClean(timerStage).build())
                        .setOperation(IMSContacts.Operation.SETTINGS_TIMER_CLEAN)
                        .build())
                .build();
    }

    // 设置好友备注(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendAliasAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        FriendDto friendDto = Dto.fromJson(params, FriendDto.class);
        if (null == friendDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_ALIAS_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendSettingsProtocol)
                .setFriendSettingsProtocol(BusinessProtocolMessages.FriendSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsFriend((BusinessProtocolEntities.TouristsFriend) friendDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.FRIEND_ALIAS)
                        .build())
                .build();
    }

    // 设置好友备注(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendAliasAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        FriendDto friendDto = Dto.fromJson(params, FriendDto.class);
        if (null == friendDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_ALIAS_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendSettingsProtocol)
                .setFriendSettingsProtocol(BusinessProtocolMessages.FriendSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredFriend((BusinessProtocolEntities.RegisteredFriend) friendDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.FRIEND_ALIAS)
                        .build())
                .build();
    }

    // 好友设置阅后即焚(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendSnapchatAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        FriendDto friendDto = Dto.fromJson(params, FriendDto.class);
        if (null == friendDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_SNAPCHAT_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendSettingsProtocol)
                .setFriendSettingsProtocol(BusinessProtocolMessages.FriendSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsFriend((BusinessProtocolEntities.TouristsFriend) friendDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SNAPCHAT_STATUS_FRIEND)
                        .build())
                .build();
    }

    // 好友设置阅后即焚(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendSnapchatAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        FriendDto friendDto = Dto.fromJson(params, FriendDto.class);
        if (null == friendDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_SNAPCHAT_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendSettingsProtocol)
                .setFriendSettingsProtocol(BusinessProtocolMessages.FriendSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredFriend((BusinessProtocolEntities.RegisteredFriend) friendDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SNAPCHAT_STATUS_FRIEND)
                        .build())
                .build();
    }

    // 设置阅后即焚时长(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendSnapchatLengthAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        FriendDto friendDto = Dto.fromJson(params, FriendDto.class);
        if (null == friendDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_SNAPCHAT_LENGTH_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendSettingsProtocol)
                .setFriendSettingsProtocol(BusinessProtocolMessages.FriendSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsFriend((BusinessProtocolEntities.TouristsFriend) friendDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SNAPCHAT_LENGTH_FRIEND)
                        .build())
                .build();
    }

    // 设置阅后即焚时长(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendSnapchatLengthAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        FriendDto friendDto = Dto.fromJson(params, FriendDto.class);
        if (null == friendDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_SNAPCHAT_LENGTH_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendSettingsProtocol)
                .setFriendSettingsProtocol(BusinessProtocolMessages.FriendSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredFriend((BusinessProtocolEntities.RegisteredFriend) friendDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SNAPCHAT_LENGTH_FRIEND)
                        .build())
                .build();
    }

    // 好友设置是否离线消息接收(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendOfflineMsgAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        FriendDto friendDto = Dto.fromJson(params, FriendDto.class);
        if (null == friendDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_OFFLINE_MSG_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendSettingsProtocol)
                .setFriendSettingsProtocol(BusinessProtocolMessages.FriendSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsFriend((BusinessProtocolEntities.TouristsFriend) friendDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.OFFLINE_MESSAGE)
                        .build())
                .build();
    }

    // 好友设置是否离线消息接收(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendOfflineMsgAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        FriendDto friendDto = Dto.fromJson(params, FriendDto.class);
        if (null == friendDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.FRIEND_OFFLINE_MSG_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendSettingsProtocol)
                .setFriendSettingsProtocol(BusinessProtocolMessages.FriendSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredFriend((BusinessProtocolEntities.RegisteredFriend) friendDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.OFFLINE_MESSAGE)
                        .build())
                .build();
    }

    // 设置群名称(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupNameAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupDto groupDto = Dto.fromJson(params, GroupDto.class);
        if (null == groupDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_NAME_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupSettingsProtocol)
                .setGroupSettingsProtocol(BusinessProtocolMessages.GroupSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsGroup((BusinessProtocolEntities.TouristsGroup) groupDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.GROUP_NAME)
                        .build())
                .build();
    }

    // 设置群名称(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupNameAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupDto groupDto = Dto.fromJson(params, GroupDto.class);
        if (null == groupDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_NAME_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupSettingsProtocol)
                .setGroupSettingsProtocol(BusinessProtocolMessages.GroupSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredGroup((BusinessProtocolEntities.RegisteredGroup) groupDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.GROUP_NAME)
                        .build())
                .build();
    }

    // 设置阅后即焚开关(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupSnapchatAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupDto groupDto = Dto.fromJson(params, GroupDto.class);
        if (null == groupDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_SNAPCHAT_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupSettingsProtocol)
                .setGroupSettingsProtocol(BusinessProtocolMessages.GroupSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsGroup((BusinessProtocolEntities.TouristsGroup) groupDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SNAPCHAT_STATUS_GROUP)
                        .build())
                .build();
    }

    // 设置阅后即焚开关(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupSnapchatAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupDto groupDto = Dto.fromJson(params, GroupDto.class);
        if (null == groupDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_SNAPCHAT_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupSettingsProtocol)
                .setGroupSettingsProtocol(BusinessProtocolMessages.GroupSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredGroup((BusinessProtocolEntities.RegisteredGroup) groupDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SNAPCHAT_STATUS_GROUP)
                        .build())
                .build();
    }

    // 设置阅后即焚时长(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupSnapchatLengthAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupDto groupDto = Dto.fromJson(params, GroupDto.class);
        if (null == groupDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_SNAPCHAT_LENGTH_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupSettingsProtocol)
                .setGroupSettingsProtocol(BusinessProtocolMessages.GroupSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsGroup((BusinessProtocolEntities.TouristsGroup) groupDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SNAPCHAT_LENGTH_GROUP)
                        .build())
                .build();
    }

    // 设置阅后即焚时长(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupSnapchatLengthAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupDto groupDto = Dto.fromJson(params, GroupDto.class);
        if (null == groupDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_SNAPCHAT_LENGTH_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupSettingsProtocol)
                .setGroupSettingsProtocol(BusinessProtocolMessages.GroupSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredGroup((BusinessProtocolEntities.RegisteredGroup) groupDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.SNAPCHAT_LENGTH_GROUP)
                        .build())
                .build();
    }

    // 设置群成员群昵称(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberNickAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupMemberDto groupMemberDto = Dto.fromJson(params, GroupMemberDto.class);
        if (null == groupMemberDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_NICK_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupMemberSettingsProtocol)
                .setGroupMemberSettingsProtocol(BusinessProtocolMessages.GroupMemberSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsGroupMember((BusinessProtocolEntities.TouristsGroupMember) groupMemberDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.GROUP_MEMBER_NICK)
                        .build())
                .build();

    }

    // 设置群成员群昵称(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberNickAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupMemberDto groupMemberDto = Dto.fromJson(params, GroupMemberDto.class);
        if (null == groupMemberDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_NICK_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupMemberSettingsProtocol)
                .setGroupMemberSettingsProtocol(BusinessProtocolMessages.GroupMemberSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredGroupMember((BusinessProtocolEntities.RegisteredGroupMember) groupMemberDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.GROUP_MEMBER_NICK)
                        .build())
                .build();
    }

    // 设置群成员备注(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberAliasAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupMemberDto groupMemberDto = Dto.fromJson(params, GroupMemberDto.class);
        if (null == groupMemberDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_ALIAS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupMemberSettingsProtocol)
                .setGroupMemberSettingsProtocol(BusinessProtocolMessages.GroupMemberSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setTouristsGroupMember((BusinessProtocolEntities.TouristsGroupMember) groupMemberDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.GROUP_MEMBER_ALIAS)
                        .build())
                .build();
    }

    // 设置群成员备注(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupMemberAliasAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        GroupMemberDto groupMemberDto = Dto.fromJson(params, GroupMemberDto.class);
        if (null == groupMemberDto) return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_MEMBER_ALIAS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupMemberSettingsProtocol)
                .setGroupMemberSettingsProtocol(BusinessProtocolMessages.GroupMemberSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setRegisteredGroupMember((BusinessProtocolEntities.RegisteredGroupMember) groupMemberDto.toProtobuf())
                        .setOperation(IMSContacts.Operation.GROUP_MEMBER_ALIAS)
                        .build())
                .build();
    }

    // 通知列表(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onNotificationsAsTouristsSender() {
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.NOTIFICATIONS_TOURISTS)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.NotificationsProtocol)
                .setNotificationsProtocol(BusinessProtocolMessages.NotificationsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .build())
                .build();
    }

    // 通知列表(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onNotificationsAsRegisteredSender() {
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.NOTIFICATIONS_REGISTERED)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.NotificationsProtocol)
                .setNotificationsProtocol(BusinessProtocolMessages.NotificationsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .build())
                .build();
    }

    // 单人(1v1)聊天
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onFriendChatMessageSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        ChatFriendMsgDto friendChatMsgDto = Dto.fromJson(params, ChatFriendMsgDto.class);
        if (null == friendChatMsgDto || null == friendChatMsgDto.getFriendDto() || null == friendChatMsgDto.getChatMessageDto())
            return null;
        String userId = UserPreferences.getUserId();
        String msgType = IMSContacts.UserType.TOURISTS_USER.equals(friendChatMsgDto.getFriendDto().getCurrentUserType()) ? IMSContacts.MsgType.FRIEND_CHAT_TOURISTS : IMSContacts.MsgType.FRIEND_CHAT_REGISTERED;
        String msgId = friendChatMsgDto.getChatMessageDto().getMsgId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(msgType)
                .setFromId(userId)
                .setToId(friendChatMsgDto.getFriendDto().getFriendUserId())
                .setTimestamp(ChatUtils.analysisTimestampInMessageId(msgId))
                .setUniqueIdentify(msgId)
                .setToken(UserPreferences.getToken())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.FriendChatProtocol)
                .setFriendChatProtocol(friendChatMsgDto.toProtobuf())
                .build();
    }

    // 多人(群)聊天
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupChatMessageSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        ChatGroupMsgDto groupChatMsgDto = Dto.fromJson(params, ChatGroupMsgDto.class);
        if (null == groupChatMsgDto || null == groupChatMsgDto.getGroupMemberDto() || null == groupChatMsgDto.getGroupMemberDto().getGroup() || null == groupChatMsgDto.getChatMessageDto())
            return null;
        String userId = UserPreferences.getUserId();
        String msgType = IMSContacts.UserType.TOURISTS_USER.equals(groupChatMsgDto.getGroupMemberDto().getCurrentUserType()) ? IMSContacts.MsgType.GROUP_CHAT_TOURISTS : IMSContacts.MsgType.GROUP_CHAT_REGISTERED;
        JLog.e(msgType);
        String msgId = groupChatMsgDto.getChatMessageDto().getMsgId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(msgType)
                .setFromId(userId)
                .setToId(groupChatMsgDto.getGroupMemberDto().getGroup().getGroupId())
                .setTimestamp(ChatUtils.analysisTimestampInMessageId(msgId))
                .setUniqueIdentify(msgId)
                .setToken(UserPreferences.getToken())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.GroupChatProtocol)
                .setGroupChatProtocol(groupChatMsgDto.toProtobuf())
                .build();
    }

    // 删除消息(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onDelFriendMessageAsTouristsSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        DeleteMessageDto deleteMessageDto = Dto.fromJson(params, DeleteMessageDto.class);
        if (null == deleteMessageDto || TextUtils.isEmpty(deleteMessageDto.getMessageIds()) || TextUtils.isEmpty(deleteMessageDto.getFriendUserId()) || TextUtils.isEmpty(deleteMessageDto.getMsgFromIds()))
            return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.DEL_FRIEND_OFF_MESSAGE_TOURIST)
                .setFromId(userId)
                .setToId(deleteMessageDto.getFriendUserId())
                .setTimestamp(System.currentTimeMillis())
                .setUniqueIdentify(GUID.random())
                .setToken(UserPreferences.getToken())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.DelFriendOffMessageProtocol)
                .setDelFriendOffMessageProtocol(BusinessProtocolMessages.DelFriendOffMessageProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .setChatMessage(BusinessProtocolEntities.ChatMessage.newBuilder()
                                .setMsgId(deleteMessageDto.getMessageIds())
                                .setText(BusinessProtocolEntities.Text.newBuilder()
                                        .setContent(deleteMessageDto.getServerPaths())
                                        .setLength(deleteMessageDto.getChatTypes())
                                        .build())
                                .build())
                        .setTouristsFriend(BusinessProtocolEntities.TouristsFriend.newBuilder()
                                .setFriendUserId(deleteMessageDto.getFriendUserId())
                                .setUserType(deleteMessageDto.getFriendUserType())
                                .build())
                        .setMsgfromId(deleteMessageDto.getMsgFromIds())
                        .setStatusDetail(deleteMessageDto.getTimestamps())
                        .build())
                .build();
    }

    // 删除消息(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onDelFriendMessageAsRegisteredSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        DeleteMessageDto deleteMessageDto = Dto.fromJson(params, DeleteMessageDto.class);
        if (null == deleteMessageDto || TextUtils.isEmpty(deleteMessageDto.getMessageIds()) || TextUtils.isEmpty(deleteMessageDto.getFriendUserId()) || TextUtils.isEmpty(deleteMessageDto.getMsgFromIds()))
            return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.DEL_FRIEND_OFF_MESSAGE_REGIST)
                .setFromId(userId)
                .setToId(deleteMessageDto.getFriendUserId())
                .setTimestamp(System.currentTimeMillis())
                .setUniqueIdentify(GUID.random())
                .setToken(UserPreferences.getToken())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.DelFriendOffMessageProtocol)
                .setDelFriendOffMessageProtocol(BusinessProtocolMessages.DelFriendOffMessageProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .setChatMessage(BusinessProtocolEntities.ChatMessage.newBuilder()
                                .setMsgId(deleteMessageDto.getMessageIds())
                                .setText(BusinessProtocolEntities.Text.newBuilder()
                                        .setContent(deleteMessageDto.getServerPaths())
                                        .setLength(deleteMessageDto.getChatTypes())
                                        .build())
                                .build())
                        .setRegisteredFriend(BusinessProtocolEntities.RegisteredFriend.newBuilder()
                                .setFriendUserId(deleteMessageDto.getFriendUserId())
                                .setUserType(deleteMessageDto.getFriendUserType())
                                .build())
                        .setMsgfromId(deleteMessageDto.getMsgFromIds())
                        .setStatusDetail(deleteMessageDto.getTimestamps())
                        .build())
                .build();
    }

    // 离线消息(游客)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onOffFriendMessageAsTouristsSender(String page) {
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GET_OFF_MESSAGE_TOURIST)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.OffFriendMessageListProtocol)
                .setOffFriendMessageListProtocol(BusinessProtocolMessages.OffFriendMessageListProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.TOURISTS_USER)
                        .setPage(ParseUtils.parseInt(page, 1))
                        .setTouristsUser(BusinessProtocolEntities.TouristsUser.newBuilder().setTemporaryId(userId).build())
                        .build())
                .build();
    }

    // 离线消息(注册用户)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onOffFriendMessageAsRegisteredSender(String page) {
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GET_OFF_MESSAGE_REGIST)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.OffFriendMessageListProtocol)
                .setOffFriendMessageListProtocol(BusinessProtocolMessages.OffFriendMessageListProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setPage(ParseUtils.parseInt(page, 1))
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder().setUserId(userId).build())
                        .build())
                .build();
    }

    // 离线消息(群组)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onGroupOfflineMessageSender(String page) {
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.GROUP_CHART_OFF_LINE_MSG)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.OfflineGroupMessageProtocol)
                .setOfflineGroupMessageProtocol(BusinessProtocolMessages.OfflineGroupMessageProtocol.newBuilder()
                        .setPage(ParseUtils.parseInt(page, 1))
                        .setUserId(userId)
                        .build())
                .build();
    }

    // 检查更新
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onCheckForUpdatesSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        VersionDto versionDto = Dto.fromJson(params, VersionDto.class);
        if (versionDto == null) return null;
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.CHECK_FOR_UPDATES)
                .setFromId(UserPreferences.getUserId())
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setToken(UserPreferences.getToken())
                .setUniqueIdentify(GUID.random())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.CheckForUpdatesProtocol)
                .setCheckForUpdatesProtocol(versionDto.toProtobuf())
                .build();
    }

    // 删除消息(群)
    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onDelGroupMessageSender(String params) {
        if (TextUtils.isEmpty(params)) return null;
        DelGroupMsgDto deleteMessageDto = Dto.fromJson(params, DelGroupMsgDto.class);
        if (null == deleteMessageDto || TextUtils.isEmpty(deleteMessageDto.getMsgIds()) || TextUtils.isEmpty(deleteMessageDto.getGroupId()) || TextUtils.isEmpty(deleteMessageDto.getMemberIds()))
            return null;
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.DEL_GROUP_OFF_MESSAGE)
                .setFromId(userId)
                .setToId(deleteMessageDto.getGroupId())
                .setTimestamp(System.currentTimeMillis())
                .setUniqueIdentify(GUID.random())
                .setToken(UserPreferences.getToken())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.DelGroupOffMessageProtocol)
                .setDelGroupOffMessageProtocol(BusinessProtocolMessages.DelGroupOffMessageProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setUserId(userId)
                        .setMsgIds(deleteMessageDto.getMsgIds())
                        .setChatTypes(deleteMessageDto.getChatTypes())
                        .setServerPaths(deleteMessageDto.getServerPaths())
                        .setMemberIds(deleteMessageDto.getMemberIds())
                        .setGroupId(deleteMessageDto.getGroupId())
                        .setStatusDetail(deleteMessageDto.getTimestamps())
                        .build())
                .build();
    }

    private BusinessProtocolMessageStandard.UnifiedEntranceMessage onPersonalSettingsMessageSender() {
        String userId = UserPreferences.getUserId();
        BusinessProtocolMessageStandard.Head head = BusinessProtocolMessageStandard.Head.newBuilder()
                .setMsgType(IMSContacts.MsgType.PERSONAL_SETTINGS_INFO)
                .setFromId(userId)
                .setToId(IMSContacts.MsgType.SET_MSG_TYPE_TO_ID)
                .setTimestamp(System.currentTimeMillis())
                .setUniqueIdentify(GUID.random())
                .setToken(UserPreferences.getToken())
                .build();
        return BusinessProtocolMessageStandard.UnifiedEntranceMessage.newBuilder()
                .setHead(head)
                .setDataType(BusinessProtocolMessageStandard.UnifiedEntranceMessage.DataType.PersonalSettingsProtocol)
                .setPersonalSettingsProtocol(BusinessProtocolMessages.PersonalSettingsProtocol.newBuilder()
                        .setUserType(IMSContacts.UserType.REGISTERED_USER)
                        .setRegisteredUser(BusinessProtocolEntities.RegisteredUser.newBuilder()
                                .setUserId(userId)
                                .build())
                        .build())
                .build();
    }
}
